package com.yyh1;

public class Guaiwu {
    //属性
    //怪物名字
    public String name;
    //生命值
    public int shengmingzhi;
    //攻击力
    public int gongjili;

    public Guaiwu(String name, int shengmingzhi, int gongjili) {
        this.name = name;
        setShengmingzhi(shengmingzhi);
        this.gongjili = gongjili;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getShengmingzhi() {
        return shengmingzhi;
    }

    public void setShengmingzhi(int shengmingzhi) {
        this.shengmingzhi = shengmingzhi>0?shengmingzhi:0;
    }

    public int getGongjili() {
        return gongjili;
    }

    public void setGongjili(int gongjili) {
        this.gongjili = gongjili;
    }

    //行为
    //攻击
    public void attack(){
        System.out.println("怪物"+name+"展开攻击");
    }
    public void move(){
        System.out.println("我是"+name+",正在移动");
    }
    // 通用攻击方法
    public String showGuai() {
        return "当前生命值是："+shengmingzhi+"\n"+
                "攻击力是："+gongjili;
    }
}
